import tkinter as tk
from tkinter import simpledialog as sd


class application(tk.Frame):
    def __init__(self,master=None):
        self.master=master
        super().__init__(master)
        self.creatWidget()

    def creatWidget(self):
        self.l=tk.Label(self.master,text=f"我今年18了")
        self.l.pack()
        self.btn=tk.Button(self.master,text='多大了？',command=self.show)
        self.btn.pack()


    def show(self):
        ai=sd.askinteger(title='询问年龄',prompt='你多大了？',initialvalue=17,minvalue=1,maxvalue=28)
        self.l.config(text=f'我今年{ai}了')

window=tk.Tk()
window.geometry('1000x300+300+200')
app=application(window)
window.mainloop()
